<%--

  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the latest version of the GNU Lesser General
  Public License as published by the Free Software Foundation;

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with this program (LICENSE.txt); if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

--%>
<%@ page errorPage="/WEB-INF/jsp/error.jsp"
    contentType="text/html; charset=utf-8"
%>
<%@page import="org.jamwiki.servlets.ServletUtilEx"%>
<%@page import="org.jamwiki.servlets.WikiPageInfo"%>
<%@page import="org.jamwiki.servlets.LinkUtilEx"%>

<%@ include file="page-init.jsp" %>
<%
	WikiPageInfo pageInfo = (WikiPageInfo)request.getAttribute("pageInfo");
%>

<style type="text/css">
#wiki-page{
	background-color:#FFFFFF;
	padding:0;
}
#wiki-content{
	margin:0;
	padding:0;
}
#contents{
	border:0;
	padding:8px;
}
#content-article{
	margin:0;
	+margin-top:-18px; /* IE7 */
	_margin-top:-18px; /* IE6 */ 
}

</style>

<script type="text/javascript">
<% 
if ("true".equals(request.getParameter("embed"))) { 
	out.print("var embed = true;");
}else{
	out.print("var embed = false;");
}
%>

if(parent == self && null == opener){
	if(!embed){
		document.location = document.location.href + (document.location.href.indexOf("?") > 0 ? "&embed=false" : "?embed=false");
	}
}
</script>

<c:if test="${empty notopic}">
	<c:if test="${!empty topicObject}">
	<c:choose>
		<c:when test="${topicImage}">
			<%if(ServletUtilEx.isTopicEditable(pageInfo)){%>
				<c:set var="uploadDestination" scope="request" value="${pageInfo.topicName}"/>
				<jsp:include page="embed-upload.jsp"></jsp:include>
			<%}else{%>
				<div id="content-article" style="padding:0;">
				<c:if test="${topicImage}">
					<h1 id="contents-header">
						<span style="float:right;font-size:10pt">
						<input type="button" name="cancel" value="<fmt:message key="common.return"/>" onclick="history.back(-1);" />
						</span>
						<span>					
						<fmt:message key="${pageInfo.pageTitle.key}"><fmt:param value="${pageInfo.pageTitle.params[0]}" /></fmt:message>
						</span>
					</h1>
					<br/>		
					<a href="<c:out value="${fileVersions[0].url}" />" class="wikiimg"><jamwiki:image value="${topicObject.name}" maxWidth="800" maxHeight="600" allowEnlarge="false" /></a>
				</c:if>
				<c:out value="${topicObject.topicContent}" escapeXml="false" />
				</div>
			<%}	%>
		</c:when>
		<c:otherwise>
			<span style="position:absolute;top:0;right:0;height:14;margin:0;padding:0;display:inline">
			<a title="<fmt:message key="tab.common.edit"/>" 
			    href="<%=LinkUtilEx.buildTopicEditUrl(pageInfo.getVirtualWikiName(),pageInfo.getTopicName(),true)%>"><img src="<%=context%>/images/edit_small.jpg" border="0"/></a>
			</span>	
			<div id="content-article" style="padding:0;">
			<c:if test="${topicImage}">
				<h1 id="contents-header"><fmt:message key="${pageInfo.pageTitle.key}"><fmt:param value="${pageInfo.pageTitle.params[0]}" /></fmt:message></h1>
				<br/>		
				<a href="<c:out value="${fileVersions[0].url}" />" class="wikiimg"><jamwiki:image value="${topicObject.name}" maxWidth="800" maxHeight="600" allowEnlarge="false" /></a>
			</c:if>
			<c:out value="${topicObject.topicContent}" escapeXml="false" />
			</div>
		</c:otherwise>
	</c:choose>
	</c:if>
</c:if>
<c:if test="${!empty notopic}">
<div class="message"><fmt:message key="${notopic.key}"><fmt:param value="${notopic.params[0]}" /><fmt:param><jamwiki:link value="${notopic.params[0]}" text="${notopic.params[0]}" /></fmt:param></fmt:message></div>
</c:if>